/**
 ******************************************************************************
 * @file    bsp_uart.h
 * @author  Iron
 * @date    2020-01-01
 * @version v1.0
 * @brief   bsp_usart header file
 */

#ifndef __BSP_USART_H
#define __BSP_USART_H

#ifdef __cplusplus
extern "C" {
#endif

/* Exported includes ---------------------------------------------------------*/
#include "bsp.h"

/* Exported types ------------------------------------------------------------*/
typedef enum
{
    BSP_UART0,
    BSP_UART1,
    BSP_UART_MAX,
} bsp_uart_id_t;

/* uart bps */
#ifndef NDEBUG
/* DEBUG */
#define BSP_UART1_BPS_DEFAULT   9600
#define BSP_UART2_BPS_DEFAULT   115200
#else
/* RELEASE */
#define BSP_UART1_BPS_DEFAULT   9600
#define BSP_UART2_BPS_DEFAULT   9600
#endif

/* Exported constants --------------------------------------------------------*/
/* Exported macro ------------------------------------------------------------*/
/* Exported functions prototypes ---------------------------------------------*/

int32_t bsp_uart_poll_tx(bsp_uart_id_t uart_id, uint8_t *txbuf, size_t txbuf_size, uint32_t timeout_ms);

int32_t bsp_uart_irq_tx(bsp_uart_id_t uart_id, uint8_t *txbuf, size_t txbuf_size, uint32_t timeout_ms);

int32_t bsp_uart_irq_rx(bsp_uart_id_t uart_id, uint8_t *rxbuf, size_t rxbuf_size, uint32_t timeout_ms);

int32_t bsp_uart_get_rxfifo_length(bsp_uart_id_t uart_id);

int32_t bsp_uart_config(bsp_uart_id_t uart_id, uint32_t bps);

int32_t bsp_uart_init(void);


/**
 * @}
 */

#ifdef __cplusplus
}
#endif

#endif /* __BSP_USART_H */

/******************* (C)COPYRIGHT 2020 ***** END OF FILE *********************/
